﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Core;

namespace DAL
{
    public class ReSubmitRecordDAL : SyncBase<Model.ReSubmitRecord>
    {
        static ReSubmitRecordDAL()
        {
            StringBuilder strSql = new StringBuilder();
            ReSubmitRecordDAL.addSQL = @"insert into TempReSubmitRecord(
ArrangeID,ResourceID,StudentID,StudentName,EndTime,EndPoint,IsSubmit,TimeInterval,ResourceType,RecordTime)
 values (
@ArrangeID,@ResourceID,@StudentID,@StudentName,@EndTime,@EndPoint,@IsSubmit,@TimeInterval,@ResourceType,@RecordTime)";
            ReSubmitRecordDAL.tbName = "TempReSubmitRecord";
            ReSubmitRecordDAL.remoteUrl = "/Ayyfford/AddReSubmitRecord";
            ReSubmitRecordDAL.setVal = (lt) =>
            {
                StringBuilder sb = new StringBuilder();
                string _ids = string.Empty;
                if (lt != null && lt.Count > 0)
                {
                    lt.ForEach(t =>
                    {
                        _ids += t.ID + ",";
                        sb.AppendFormat("({0},{1},{2},{3},{4},{5},{6},{7},{8},{9}),",
                            t.ArrangeID.NullNumber(), t.ResourceID.NullNumber(), t.StudentID.NullNumber(), t.StudentName.NullString(), t.EndTime.NullDate(), t.EndPoint.NullNumber(), t.IsSubmit ? 1 : 0, t.TimeInterval.NullNumber(), t.ResourceType.NullString(), t.RecordTime.NullDate());
                    });
                }
                return new Tuple<string, string>(sb.ToString(), _ids);
            };
        }

        new public static void SaveEntity(Model.ReSubmitRecord t)
        {
            SyncBase<Model.ReSubmitRecord>.SaveEntity(t);
        }

        new public static void AsyncData()
        {
            SyncBase<Model.ReSubmitRecord>.AsyncData();
        }
    }
}
